AvgProbEventCurve <- function(p,N) {
  P = numeric(N+1);
  Nf = factorial(N);
  for (k in 1:N) {
    kf  = factorial(k);
    Nkf = factorial(N-k);
    E = Nf/(kf*Nkf);
    pk = p^k;
    pNk = (1-p)^(N-k);
    P[k] <- E * pk * pNk;
#     print(kf)
#     print(Nkf)
#     print(E)
#     print(pk)
#     print(pNk)
#     print(P)
  }
  return(P)
}